上面的幾項規則看看下面簡單範例:
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: my-destination-rule
spec:
host: my-svc
trafficPolicy: #默認的策略模型為隨機
loadBalancer:
simple: RANDOM
subsets:
- name: v1 #subset1流量轉發具有標籤version:v1的deployment對應服務上
labels:
version: v1
- name: v2 #subset2流量轉發具有標籤version:v2的deployment對應服務上,指定策略輪詢
labels:
version: v2
trafficPolicy:
loadBalancer:
simple: ROUND_ROBIN
- name: v3 #subset3流量轉發具有標籤version:v3的deployment對應服務上
labels:
version: v3
註:
這邊解釋一下子集流量,每個子集由一個或多個labels定義,在上例子中V1與V3網路traffic策略為隨機(RANDOM)V2網路策略為輪詢(ROUND_ROBIN)導入對應label version。